using UnityEngine;

//巡逻状态
public class EnemyPatrolState : EnemyState
{
    public EnemyPatrolState(EnemyFSM manager, string animationName) : base(manager, animationName) { }

    public override void OnEnter()
    {
        base.OnEnter();
        
        //翻转
        manager.FlipTo();
        
        parameter.currentSpeed = parameter.moveSpeed;
    }

    public override void OnUpdate()
    {
        base.OnUpdate();
        // 如果被击中了，转换到受击状态
        if (parameter.isHurt)
        {
            manager.TransitionState(StateType.Hit);
        }

        //如果在悬崖或者触碰墙壁，转换到空闲状态
        if(!parameter.check.isTouchGround || parameter.check.isTouchWall){
            manager.TransitionState(StateType.Idle);
        }
        // 转换到反应状态
        if (parameter.isChase)
        {
            manager.TransitionState(StateType.React);
        }
    }
    
    public override void OnFixedUpdate()
    {
        base.OnFixedUpdate();
        Move();
    }

    public override void OnExit()
    {
        base.OnExit();
    }
}
